package com.cuhk.gulimall.product.entity;

import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;

import java.io.Serializable;

import com.cuhk.common.valid.AddGroup;
import com.cuhk.common.valid.ListValue;
import com.cuhk.common.valid.UpdateGroup;
import com.cuhk.common.valid.UpdateStatus;
import lombok.Data;
import org.hibernate.validator.constraints.URL;

import javax.validation.constraints.*;

/**
 * 品牌
 * 
 * @author chenyuijing
 * @email torchsam@aliyun.com
 * @date 2024-06-10 11:23:16
 */
@Data
@TableName("pms_brand")
public class BrandEntity implements Serializable {
	private static final long serialVersionUID = 1L;

	/**
	 * 品牌id
	 */
	@NotNull(message = "修改品牌时id不能为空", groups = {UpdateGroup.class, UpdateStatus.class})
	@Null(message = "新增品牌时id必须为空", groups = {AddGroup.class})
	@TableId
	private Long brandId;
	/**
	 * 品牌名
	 */
	@NotBlank(message = "品牌名称不能为空", groups = {AddGroup.class, UpdateGroup.class})
	private String name;
	/**
	 * 品牌logo地址
	 */
	@NotBlank(message = "品牌logo不能为空", groups = {AddGroup.class, UpdateGroup.class})
	@URL(message = "品牌logo必须是一个合法的URL", groups = {AddGroup.class, UpdateGroup.class})
	private String logo;
	/**
	 * 介绍
	 */
	@NotBlank(message = "品牌描述不能为空", groups = {AddGroup.class, UpdateGroup.class})
	private String descript;
	/**
	 * 显示状态[0-不显示；1-显示]
	 */
	@ListValue(values = {0, 1}, groups = {AddGroup.class, UpdateGroup.class, UpdateStatus.class})
	private Integer showStatus;
	/**
	 * 检索首字母
	 * 利用@Pattern注解
	 * 对自定义的一些规则利用正则表达式进行检验
	 */
	@NotBlank(message = "检索字母不能为空", groups = {AddGroup.class})
	@Pattern(regexp="^[a-zA-Z]$", message = "检索字母不符合规范(字母且一位)", groups = {AddGroup.class})
	private String firstLetter;
	/**
	 * 排序
	 */
	@NotNull(message = "排列顺序不能为空", groups = {AddGroup.class})
	@Min(value = 0, message = "排序字段不符合规范(请填写大于等于0的整数)", groups = {AddGroup.class})
	private Integer sort;

}
